package fr.jade.fraclite;

import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.api.Type;
import org.objectweb.fractal.api.factory.Factory;
import org.objectweb.fractal.api.type.ComponentType;
import org.objectweb.fractal.api.type.InterfaceType;

import fr.jade.fraclite.factory.BasicGenericFactory;
import fr.jade.fraclite.type.BasicTypeFactory;


public class FracLite implements Factory {

  /**
   * The bootstrap component.
   */

  private static Component bootstrapComponent;

  // -------------------------------------------------------------------------
  // Implementation of the Factory interface
  // -------------------------------------------------------------------------

  /**
   * @return <tt>null</tt>.
   */

  public Type getFcInstanceType () {
    return null;
  }

  /**
   * @return <tt>null</tt>.
   */

  public Object getFcControllerDesc () {
    return null;
  }

  /**
   * @return <tt>null</tt>.
   */

  public Object getFcContentDesc () {
    return null;
  }

  public Component newFcInstance () {
    if (bootstrapComponent == null) {
      BasicTypeFactory typeFactory = new BasicTypeFactory();
      BasicGenericFactory genericFactory = new BasicGenericFactory();
      genericFactory.weaveableTF = typeFactory;
      try {
      // use the pre bootstrap component to create the real bootstrap component
      ComponentType t = typeFactory.createFcType(new InterfaceType[0]);
      bootstrapComponent = genericFactory.newFcInstance(t, "bootstrap", null);
      } catch (Exception e) {
        e.printStackTrace();
        System.exit(0);
      }
    }
    return bootstrapComponent;
  }

}
